var t = require("../../utils/config.js");

Page({
    data: {
        formSettingId: "",
        list: [],
        page: 1,
        isEnd: !1
    },
    onLoad: function(t) {
        this.setData({
            formSettingId: t.id
        }), this.loadDataSource();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.page = 1, this.loadDataSource();
    },
    onReachBottom: function() {
        this.data.isEnd || (this.data.page++, this.loadDataSource());
    },
    onShareAppMessage: function() {},
    loadDataSource: function() {
        var a = this, e = wx.getStorageSync("userId"), n = wx.getStorageSync("serviceProviderId");
        1 == this.data.page && (a.setData({
            isEnd: !1
        }), a.data.list = []), wx.request({
            url: t.urlList.API_FORM_LOG,
            data: {
                page: a.data.page,
                formSettingId: a.data.formSettingId,
                rows: 10,
                userId: e,
                serviceProviderId: n
            },
            header: {
                "content-type": "application/json"
            },
            success: function(t) {
                a.setData({
                    list: a.data.list.concat(t.data.data)
                }), t.data.data.length < 10 && (a.data.page--, a.setData({
                    isEnd: !0
                })), wx.stopPullDownRefresh();
            }
        });
    },
    goToDetail: function(t) {
        var a = this, e = t.currentTarget.dataset.index, n = a.data.list[e];
        wx.navigateTo({
            url: "formSettingDetail?formId=" + n.id + "&name=" + n.formName
        });
    }
});